var t = require("../export.js"), o = require("./timer.js");

getApp();

Page({
    data: {
        time: "00:00:00",
        cost: 0,
        options: {},
        ConfigInfo: []
    },
    onLoad: function(t) {
        var n = this;
        this.setData({
            options: t
        }), o.start(function(t) {
            n.timing(t);
        }), this.getConfigInfo(t);
    },
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    goIndex: function() {
        var n = this.data.options;
        t.requestUtil.post(t._DuoguanData.duoguan_host_api_url + "/index.php/addon/DuoguanCar/Apiform/cancel.html", n, function(t) {
            1 == t.code && (console.log(222222), o.stop(), wx.switchTab({
                url: "/pages/car/index/index"
            }));
        });
    },
    timing: function(n) {
        console.log(n);
        var a = this;
        if ((n = n) > 21599) a.setData({
            time: "6小时了,请拨打电话"
        }); else {
            if (n % 10 == 0) {
                var i = this.data.options;
                t.requestUtil.post(t._DuoguanData.duoguan_host_api_url + "/index.php/addon/DuoguanCar/Api/tiShi.html", i, function(t) {
                    console.log(t), 1 == t.code && wx.showModal({
                        title: "提示",
                        showCancel: !1,
                        content: "已受理",
                        success: function(t) {
                            t.confirm && (o.stop(), wx.switchTab({
                                url: "/pages/car/index/index"
                            }));
                        }
                    });
                }, this, {
                    isShowLoading: !1
                });
            }
            this.formatSeconds(n);
        }
    },
    formatSeconds: function(t) {
        var o = this, n = 0, a = 0;
        (t = t) < 60 || (t < 3600 ? (n = parseInt(t / 60), t %= 60) : (n = parseInt(t / 60), 
        t %= 60, a = parseInt(n / 60), n %= 60)), o.setData({
            time: this.formatTime(a) + ":" + this.formatTime(n) + ":" + this.formatTime(t)
        });
    },
    formatTime: function(t) {
        return t < 10 ? "0" + t : t + "";
    },
    charging: function(t) {
        t.data.seconds < 600 && t.setData({
            cost: 1
        });
    },
    getConfigInfo: function(o) {
        var n = this;
        t.requestUtil.post(t._DuoguanData.duoguan_host_api_url + "/index.php/addon/DuoguanCar/Api/getConfigInfo.html", o, function(t) {
            n.setData({
                ConfigInfo: t
            });
        });
    },
    callPhone: function(t) {
        var o = t.currentTarget.dataset.mobile;
        console.log(t.currentTarget.dataset.mobile), wx.makePhoneCall({
            phoneNumber: o
        });
    }
});